package com.aaa.project.controller;


import com.aaa.entity.BAppeal;
import com.aaa.project.service.IBAppealService;
import com.aaa.project.util.GetBid;
import com.aaa.util.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <p>
 * 商家申诉表 前端控制器
 * </p>
 *
 * @author zhangxuhui
 * @since 2023-02-19
 */
@RestController
@RequestMapping("/b-appeal")
public class BAppealController {

    @Resource
    private IBAppealService appealService;
    @Resource
    private GetBid getBid;
    @PostMapping("shensu")
    public Result shensu(String telephone, BAppeal appeal){
        Result result = new Result();
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String addTime = sdf.format(date);
        appeal.setAppealTime(addTime);
        String bid = getBid.getbid(telephone);
        appeal.setBusinessId(bid);
        appeal.setStatus(0);
        boolean saveresult = appealService.save(appeal);

        result.setData(saveresult);
        if(saveresult==true){
            result.setMsg("申诉已提交，请等待回复");
        }else {
            result.setMsg("申诉提交失败，请重新提交");
        }
        return  result;
    }

}

